#ifndef _PQ_H_
#define _PQ_H_

struct __td;

/**
 * Priority queue structure. In our kernel, a priority queue is a
 * doubly-linked circular list of task descriptors. The list is maintained
 * by the next/prev pointers in the task descriptor; this structure merely
 * provides a pointer to the head.
 */
typedef struct __pq {
  struct __td *head;             // head of priority queue
  int size;             // number of elements in this queue
} pq;

/* Initializes the priority queue */
void PqInit( pq *queue );

/* Returns whether the priority queue is empty */
int PqEmpty( pq *queue );

/* Returns the size of the queue */
int PqSize( pq *queue );

/* Returns the head of the queue (doesn't pop) */
struct __td* PqFront( pq *queue );

/* Returns the head of the queue and pops it off the queue */
struct __td* PqPopFront( pq *queue );

/* Pushes the task to the back of the queue */
void PqPushBack( pq *queue, struct __td *task );

/* Removes the task from the queue */
int PqErase( pq *queue, struct __td *task );

#endif
